using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using Csla;
using Csla.Data;

using buildingLib.xcategory;

namespace _dmis.xcategory
{
    public partial class XItemDetailTool : _dmis.UIToolBase
    {
        Guid m_itemID;
        public XItemDetailTool(Guid ItemID)
        {
            InitializeComponent();
            m_itemID = ItemID;
        }

        private void XItemDetailTool_Load(object sender, EventArgs e)
        {
            GetItemDetail(m_itemID);
        }

        private void xItemIODetailDataGridView_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
        {
            if (e.RowIndex >= xItemIODetailDataGridView.Rows.Count)
                return;           
            xItemIODetailDataGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor =((int) xItemIODetailDataGridView.Rows[e.RowIndex].Cells["Type"].Value == 0)?Color.LightGreen : Color.Pink;
        }

        public void GetItemDetail(Guid itemID)
        {
            m_itemID = itemID;
            xItemIODetailBindingSource.DataSource = new SortedBindingList<XIOItem>(buildingLib.xcategory.XItemIODetail.GetIOItemDetail(m_itemID));
        }

        private void xItemIODetailDataGridView_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if(this.xItemIODetailDataGridView.SelectedRows.Count!=0)
            {
                XIOTicketDlg ticketdlg = new XIOTicketDlg((Guid)xItemIODetailDataGridView.SelectedRows[0].Cells["Ticketid"].Value);
                ticketdlg.ShowDialog(this);
            }
            
        }
    }
}

